<template>
  <view class="page-container">
    <Search
      :searchValue="searchValue"
      :searchResultList="searchResultList"
      @handleSearch="handleReplaceSearch"
    ></Search>
  </view>
</template>

<script setup>
    import {ref} from "vue";
    import Search from "@/components/Search/index.vue";
    import {searchScenicSpotList} from "@/api/ticket";

    const searchValue = ref("");
    const searchResultList = ref([]);

    const handleSearch = async (searchValue) => {
      await searchScenicSpotList({name:searchValue}).then(res => {
        searchResultList.value = res.result;
      })
    };
    const handleReplaceSearch = (event) => {
      handleSearch(event);
    };

    onLoad((options) => {
      let {searchValue:_searchValue} = options;
      searchValue.value = _searchValue;
      handleSearch(searchValue.value);
    });
</script>

<style lang="scss" scoped>
  .page-container {
    padding: 40rpx 30rpx 0 30rpx;
    box-sizing: border-box;
  }
</style>
